home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 8.6 KB | 302 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: Frame.cpp
- // Release Version: $ ODF 2 $
- //
- // Author: M.Boetcher
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "Embed.hpp"
-
- #ifndef FRAME_H
- #include "Frame.h"
- #endif
-
- #ifndef PART_H
- #include "Part.h"
- #endif
-
- #ifndef PROXY_H
- #include "Proxy.h"
- #endif
-
- #ifndef COMMAND_H
- #include "Command.h"
- #endif
-
- #ifndef CONTENT_H
- #include "Content.h"
- #endif
-
- #ifndef SELECT_H
- #include "Select.h"
- #endif
-
- #ifndef DEFINES_K
- #include "Defines.k"
- #endif
-
- // ----- Framework Includes -----
-
- #ifndef FWUTIL_H
- #include "FWUtil.h"
- #endif
-
- #ifndef FWCONTXT_H
- #include "FWContxt.h"
- #endif
-
- #ifndef FWPRESEN_H
- #include "FWPresen.h"
- #endif
-
- #ifndef FWPXYFRM_H
- #include "FWPxyFrm.h"
- #endif
-
- #ifndef FWGROWBX_H
- #include "FWGrowBx.h"
- #endif
-
- #ifndef FWSCLBAR_H
- #include "FWSclBar.h"
- #endif
-
- #ifndef FWFCTCLP_H
- #include "FWFctClp.h"
- #endif
-
- // ----- OS Layer Includes -----
-
- #ifndef FWODGEOM_H
- #include "FWODGeom.h"
- #endif
-
- #ifndef FWRECSHP_H
- #include "FWRecShp.h"
- #endif
-
- #ifndef FWMNUBAR_H
- #include "FWMnuBar.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_Module_OpenDoc_Commands_defined
- #include <CmdDefs.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdProps_defined
- #include <StdProps.xh>
- #endif
-
- //========================================================================================
- // Runtime information
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment odfembed
- #endif
-
- FW_DEFINE_AUTO(CEmbedFrame)
-
- //========================================================================================
- // CLASS CEmbedFrame
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // CEmbedFrame::CEmbedFrame
- //----------------------------------------------------------------------------------------
-
- CEmbedFrame::CEmbedFrame(Environment* ev,
- ODFrame* odFrame,
- FW_CPresentation* presentation,
- CEmbedPart* part,
- CEmbedContent* content) :
- FW_CEmbeddingFrame(ev, odFrame, presentation, part),
- FW_MDraggableFrame(ev, this),
- FW_MDroppableFrame(ev, this),
- fPart(part),
- fContent(content)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CEmbedFrame::~CEmbedFrame
- //----------------------------------------------------------------------------------------
-
- CEmbedFrame::~CEmbedFrame()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CEmbedFrame::Draw
- //----------------------------------------------------------------------------------------
-
- void CEmbedFrame::Draw(Environment* ev, ODFacet* odFacet, ODShape* invalidShape)
- {
- FW_CViewContext vc(ev, this, odFacet, invalidShape);
-
- FW_CRectShape::RenderRect(vc, GetBounds(ev), FW_kFill, FW_kRGBBlue);
- }
-
- //----------------------------------------------------------------------------------------
- // CEmbedFrame::Draw
- //----------------------------------------------------------------------------------------
-
- void CEmbedFrame::CreateSubViews(Environment* ev)
- {
- // ----- Create a GrowBox only in root frame
- // Note: You do not need CreateSubViews if the views are defined in resources.
- // See the Container or Form samples
-
- if (this->IsRoot(ev))
- {
- FW_CRect frameRect = GetBounds(ev);
- FW_CPoint sbSize = FW_CScrollBar::GetDefaultScrollBarSize();
- frameRect.right -= sbSize.x;
- frameRect.bottom -= sbSize.y;
-
- FW_CGrowBox* growBox = new FW_CGrowBox(ev, this, 0, frameRect.BotRight());
- }
-
- }
-
- //----------------------------------------------------------------------------------------
- // CEmbedFrame::CanAcceptDrop
- //----------------------------------------------------------------------------------------
- // As an embedding frame I can accept anything
-
- ODDragResult CEmbedFrame::CanAcceptDrop(Environment *ev, ODDragItemIterator* dragInfo)
- {
- FW_UNUSED(ev);
- FW_UNUSED(dragInfo);
- return TRUE;
- }
-
- //---------------------------------------------------------------------------------------
- // CEmbedFrame::DoAdjustMenus
- //---------------------------------------------------------------------------------------
-
- FW_Handled CEmbedFrame::DoAdjustMenus(Environment* ev, FW_CMenuBar* menuBar, FW_Boolean hasMenuFocus, FW_Boolean isRoot)
- {
- FW_UNUSED(isRoot);
- if (hasMenuFocus)
- {
- // Check clipboard for a part to paste
- menuBar->EnableCommand(ev, kODCommandPaste, HasPropertyOnClipboard(ev, kODPropContentFrame, NULL));
-
- // If an embedded part is selected, change Copy menu item to "Copy Part"
- if (GetPresentation(ev)->GetSelection(ev)->IsEmpty(ev))
- menuBar->SetItemString(ev, kODCommandCopy, FW_CString32("Copy"));
- else
- menuBar->SetItemString(ev, kODCommandCopy, FW_CString32("Copy Part"));
- }
-
- return FW_kNotHandled;
- }
-
- //----------------------------------------------------------------------------------------
- // CEmbedFrame::CreateFrameShape
- //----------------------------------------------------------------------------------------
- // Returns a new shape equals to my frame shape inset by eight pixels. Otherwise I can't drop
- // anything
-
- ODShape* CEmbedFrame::CreateFrameShape(Environment* ev)
- {
- FW_CRect bounds = GetBounds(ev);
- bounds.Inset(kBorder);
- bounds.Place(FW_kFixed0, FW_kFixed0); // Frame shape always zero based
- return ::FW_NewODShape(ev, bounds);
- }
-
- //----------------------------------------------------------------------------------------
- // CEmbedFrame::FrameShapeChanged
- //----------------------------------------------------------------------------------------
- // Change the frame shape of the embedded frame to be the same as mine minus a border
-
- void CEmbedFrame::FrameShapeChanged(Environment* ev)
- {
- // Must call inherited so our "view" superclass gets adjusted.
- FW_CEmbeddingFrame::FrameShapeChanged (ev);
-
- CEmbedProxy* proxy = fContent->GetProxy();
- if (proxy != NULL)
- {
- FW_CAcquiredODFrame embeddedFrame = proxy->AcquireEmbeddedFrame(ev, this);
-
- FW_CAcquiredODShape frameShape = CreateFrameShape(ev);
- embeddedFrame->ChangeFrameShape(ev, frameShape, NULL);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CEmbedFrame::NewClipboardCommand
- //----------------------------------------------------------------------------------------
-
- FW_CClipboardCommand* CEmbedFrame::NewClipboardCommand(Environment* ev, ODCommandID commandID)
- {
- FW_Boolean undoAble = TRUE;
- if (commandID == kODCommandPasteAs)
- undoAble = FALSE;
-
- return FW_NEW(CEmbedEditCommand, (ev,
- commandID,
- fContent,
- this,
- GetPresentation(ev)->GetSelection(ev),
- undoAble));
- }
-
- //----------------------------------------------------------------------------------------
- // CEmbedFrame::NewDropCommand
- //----------------------------------------------------------------------------------------
-
- FW_CDropCommand* CEmbedFrame::NewDropCommand(Environment* ev,
- FW_CFrame* frame,
- ODDragItemIterator* dropInfo,
- ODFacet* odFacet,
- const FW_CPoint& dropPoint)
- {
- FW_UNUSED(frame);
- return FW_NEW(CEmbedDropCommand, (ev, fContent, this, dropInfo, odFacet, dropPoint));
- }
-
- //----------------------------------------------------------------------------------------
- // CEmbedFrame::NewDragCommand
- //----------------------------------------------------------------------------------------
-
- FW_CDragCommand* CEmbedFrame::NewDragCommand(Environment *ev, FW_CFrame* theFrame, const FW_CMouseEvent& theMouseEvent)
- {
- FW_UNUSED(theFrame);
- FW_UNUSED(theMouseEvent);
-
- return FW_NEW(CEmbedDragCommand, (ev, fContent, this, (CEmbedSelection*)GetPresentation(ev)->GetSelection(ev)));
- }
-
- //----------------------------------------------------------------------------------------
- // CEmbedFrame::NewInsertCommand
- //----------------------------------------------------------------------------------------
- FW_CInsertCommand* CEmbedFrame::NewInsertCommand(Environment* ev, const FW_PFileSpecification& fileSpec)
- {
- return FW_NEW(CEmbedInsertCommand, (ev,
- this,
- fileSpec,
- fContent));
- }
-
- //----------------------------------------------------------------------------------------
- // CEmbedFrame::DoMouseDownInEmbeddedFrameBorder
- //----------------------------------------------------------------------------------------
-
- FW_Handled CEmbedFrame::DoMouseDownInEmbeddedFrameBorder(Environment *ev, const FW_CBorderMouseEvent& theBorderMouseEvent)
- {
- Drag(ev, theBorderMouseEvent);
-
- return FW_kHandled;
- }
-
-